<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="path" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>

<title>新生报到系统</title>
<!-- <link rel="icon" href="../images/31.png置" type="image/x-icon"/> -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="text/javascript" src="${path}/js/jquery-1.11.1.min.js"></script>

<link href="${path}/css/style2.css" rel="stylesheet" type="text/css"
	media="all" />
<style type="text/css">
body {
	width: 100%;
	height: 100%;
}

.all {
	width: 1000px;
	position: absolute;
	left: 40%;
}

/* #password, #address, #phone, #qq, #sex, #date, #exampleInputFile {
	display: none;
} */
.noneAndblock {
	display: none;
}

#submit2 {
	background: #84C639;
	width: 100%;
	border: 0;
	padding: 10px 15px;
	color: #ffffff;
	-webkit-transition: 0.3s ease;
	transition: 0.3s ease;
	font-size: 14px;
	font-weight: bold;
	cursor: pointer;
	text-transform: uppercase;
}

#submit2:hover {
	background: #FAC718;
}
</style>
</head>
<body>
	<div class="all">
		<div class="main">
			<h1>新生报到系统</h1>
			<div class="w3_login">
				<div class="w3_login_module">
					<div class="module form-module">
						<div class="toggle">
							<i class="fa fa-times fa-pencil"></i>
							<div class="tooltip">切换？</div>
						</div>
						<div class="form">
							<h2 id="h1">学生报到</h2>
							<form action="/student/tloginAndregister" method="post"
								enctype="multipart/form-data">
								<input id="username" type="text" name="username"
									placeholder="姓名" required="required" maxlength="30" /> <input
									id="studentid" type="text" name="studentid" placeholder="学号"
									onkeyup="value=value.replace(/[^\d]/g,'')" required="required"
									maxlength="30" /> <input id="password" class="noneAndblock"
									type="password" name="password" placeholder="密码" maxlength="30" /><input
									id="address" class="noneAndblock" type="text"
									placeholder="家庭住址" name="address" maxlength="30" /> <input
									id="phone" class="noneAndblock" type="text" placeholder="联系电话"
									name="phone" maxlength="15"
									onkeyup="value=value.replace(/[^\d]/g,'')" /> <input id="qq"
									class="noneAndblock" type="text" placeholder="QQ" name="qq"
									maxlength="15" onkeyup="value=value.replace(/[^\d]/g,'')" />
								<div id="sex" class="noneAndblock" style="font-size: 20px">
									<label>性别:</label> <label>男</label> <input type="radio"
										value="1" name='sex' checked> <label>女</label> <input
										type="radio" value="2" name='sex'>
								</div>
								<div id="date" class="noneAndblock"
									style="padding-top: 10px; padding-bottom: 10px;">
									<label>出生年月:</label>&nbsp;<input title="出生年月"
										placeholder="出生年月" type="date" name="date" autocomplete="off" />
								</div>
								<div id="exampleInputFile" class="noneAndblock"
									style="padding-bottom: 10px;">
									<label>头像:</label><input type="file" name="file"
										style="width: 200px" />
								</div>
								<div id="codes" class="codes"
									style="width: 155px; height: 60px;">
									<input id="vcode" maxlength="4" type="text" class="blur"
										placeholder="请输入验证码" name="vcode" required="required" /> <img
										id="cpacha-img"
										src="../system/get_cpacha?vl=4&w=160&h=40&type=accountLoginCpacha"
										onclick="changeVcode()" class="code"
										style="cursor: pointer; position: relative; left: 160px; top: -60px;" />
								</div>
								<input id="submit" type="submit" value="报到"
									style="padding-top: 15px;" />
							</form>
						</div>
						<div class="form">
							<h2>账号登陆</h2>
							<form name="form2" id="regUser" accept-charset="utf-8">
								<input id="username2" type="text" name="username2"
									placeholder="用户名" required="required" maxlength="15" /> <input
									id="studentid2" type="text" name="studentid2" placeholder="学号"
									maxlength="15" /> <input id="password2" type="password"
									name="password2" placeholder="密码" required="required"
									maxlength="20" />
								<div id="codes2" class="codes"
									style="width: 155px; height: 60px;">
									<input id="vcode2" maxlength="4" type="text" class="blur"
										placeholder="请输入验证码" name="vcode2" required="required"
										maxlength="4" /> <img id="cpacha-img2"
										src="../system/get_cpacha?vl=4&w=160&h=40&type=accountLoginCpacha"
										onclick="changeVcode()" class="code"
										style="cursor: pointer; position: relative; left: 160px; top: -60px;" />
								</div>
								<div id="select" class="select"
									style="font-size: 18px; padding-bottom: 15px;">
									<label>登陆方式:</label> <label>学生</label> <input type="radio"
										value="1" name='select'> &nbsp;<label>教师</label> <input
										type="radio" value="2" name='select'>&nbsp; <label>管理员</label>
									<input type="radio" value="3" name='select' onclick="select()">
								</div>
								<input id="submit2" type="button" value="登陆" />
							</form>
						</div>
						<div class="cta">
							<a id="button_wj" href="javascript:void(0);">忘记密码?</a>
						</div>
					</div>
				</div>
			</div>
		</div>

		<script type="text/javascript">
			/* 验证码 */
			function changeVcode() {
				$(".code").attr(
						"src",
						'../system/get_cpacha?vl=4&w=160&h=40&type=accountLoginCpacha&t='
								+ new Date().getTime());
			}

			/* 登陆选择切换 */
			$("input:radio[name=select][value=1]").attr("checked", true);
			$('input[type=radio][name=select]').change(
					function() {
						if (this.value == '1') {
							$("input:radio[name=select][value!=1]").attr(
									"checked", false);
							$("input:radio[name=select][value=1]").attr(
									"checked", true);
							$("#studentid2").show();
						} else if (this.value == '2') {
							$("input:radio[name=select][value!=2]").attr(
									"checked", false);
							$("input:radio[name=select][value=2]").attr(
									"checked", true);
							$("#studentid2").hide();
						} else {
							$("input:radio[name=select][value!=3]").attr(
									"checked", false);
							$("input:radio[name=select][value=3]").attr(
									"checked", true);
							$("#studentid2").hide();
						}
					});

			/* 报到与登陆切换 */
			$('.tooltip').click(function() {
				$(this).children('i').toggleClass('fa-pencil');
				$('.form').animate({
					height : "toggle",
					'padding-top' : 'toggle',
					'padding-bottom' : 'toggle',
					opacity : "toggle"
				}, "slow");
			});

			$("input.noneAndblock").hide();
			$("input.noneAndblock").removeAttr("required");
			if ("${type}" == "error") {
				changeVcode();
				alert("${msg }");
			}
			if ("${type}" == "success") {
				alert("${msg }");
				window.location.href = 'index';
			}
			if ("${type}" == "login") {
				alert("${msg }");
				changeVcode();
				$('.toggle').click();
			}
			if ("${type}" == "register") {
				$("#codes").css({
					"display" : "none"
				});
				//#password, #address, #phone, #qq, #sex, #date, #exampleInputFile
				$("input.noneAndblock").css({
					"display" : "block"

				});
				$(".noneAndblock").css({
					"display" : "block"
				});
				//required="required"
				$("#vcode").removeAttr("required");
				$("input.noneAndblock").prop("required", "required");
				$("#username").val("${student.username}");
				$("#studentid").val("${student.studentid}");
				$("#username").prop("readonly", "readonly");
				$("#studentid").prop("readonly", "readonly");
				alert("${msg }");
				$("#h1").text("注册账号");
				$("#submit").val("注册");
			}
			//$("#username").removeAttr("required");
			//$("#username").prop("required", "required");
			$("#submit2")
					.click(
							function() {
								var username = $("#username2").val();
								var studentid = $("#studentid2").val();
								var password = $("#password2").val();
								var vcode = $("#vcode2").val();
								var item = $('input[name=select][checked]')
										.val();
								//alert(item);
								var data = $('#regUser').serialize();
								if (item == 1) {
									if (username == '' || studentid == ''
											|| password == '' || vcode == '') {
										alert('请填写完成信息再提交!');
										return;
									}
									//异步提交请求数据(学生登陆)
									$
											.ajax({
												type : 'POST',
												dataType : 'json',
												url : '/student/tlogin3',
												data : data,
												success : function(result) {
													//console.log(result);
													if (result.type == 'success') {
														alert(result.msg);
														location.href = '/student/index';
													} else {
														alert(result.msg);
														changeVcode();
													}
												}
											});
								} else {
									if (username == '' || password == ''
											|| vcode == '') {
										alert('请填写完成信息再提交!');
										return;
									}

									/* 教师登陆 */
									if (item == 2) {

									}
									/* 管理员登陆 */
									if (item == 3) {
										$
												.ajax({
													type : 'POST',
													dataType : 'json',
													url : '/admin/tAdminLogin',
													data : data,
													success : function(result) {
														//console.log(result);
														if (result.type == 'success') {
															alert(result.msg);
															location.href = '/admin/index';
														} else {
															alert(result.msg)
															changeVcode();
														}
													}
												});
									}

								}

							})
			/*忘记密码  */
			$(document)
					.ready(
							function() {
								$('#button_wj')
										.click(
												function() {
													var NameAndStudentid = prompt(
															"请输入您的姓名与学号，用#隔开",
															""); //将输入的内容赋给变量 name ，  

													//这里需要注意的是，prompt有两个参数，前面是提示的话，后面是当对话框出来后，在对话框里的默认值  

													if (NameAndStudentid) //如果返回的有内容  
													{
														//异步提交请求数据
														$
																.ajax({
																	type : 'POST',
																	dataType : 'json',
																	url : 'czpad',
																	data : {
																		NameAndStudentid : NameAndStudentid
																	},
																	success : function(
																			result) {
																		//console.log(result);
																		if (result.type == 'success') {
																			Email(NameAndStudentid);
																		} else {
																			alert(result.msg);
																		}
																	}
																});

													} else {
														alert("您未输入任何内容！");
													}

													function Email(
															NameAndStudentid) {
														var Email = prompt(
																"请输入您要重置密码要发送的邮箱",
																"");
														if (Email) {
															$
																	.ajax({
																		url : 'czpad',
																		type : 'post',
																		dataType : 'json',
																		data : {
																			NameAndStudentid : NameAndStudentid,
																			Email : Email
																		},
																		success : function(
																				result) {
																			if (result.type == 'success') {
																				alert(result.msg)
																				location.href = '/student/loginAndregister';
																			} else {
																				alert(result.msg);
																			}
																		}
																	});
														} else {
															alert("您未填写任何内容！");
														}

													}
												})

							});
		</script>
		<div style="text-align: center;">
			<p>
				版权所有：http://www.bsuc.edu.cn/<a href="http://www.bsuc.edu.cn/"
					target="_blank">唐丽红@百色学院</a>
			</p>
		</div>

	</div>
</body>
</html>